package com.ly.count.impl.user;
 
import com.ly.count.impl.user.transfer.CPlusUserTransfer;
import com.ly.count.service.user.CPlusUserService;
import com.ly.count.user.mapper.CPlusUserMapper;
import com.ly.count.user.param.CPlusUserPage;
import com.ly.count.user.po.CPlusUser;
import com.ly.count.http.CPlusResponse;
import com.ly.count.http.CPlusResponse;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ly.count.utils.ResponseModelUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

import java.util.Optional;

/**
 * Module: CPlusUser.java
 * 
 * @author liaoyong
 * @since JDK 1.8
 * @version 1.0
 * @date 2024-10-03
 * @Descriptions:
 */
@Service("cPlusUserService")
public class CPlusUserServiceImpl extends ServiceImpl<CPlusUserMapper, CPlusUser> implements CPlusUserService {
 		
 	public CPlusResponse<CPlusUser> selectOne(CPlusUser cPlusUser){
 		Wrapper<CPlusUser> queryWrapper = new QueryWrapper<>(cPlusUser);
		return ResponseModelUtils.body(getOne(queryWrapper));
 	
 	}
	
	public CPlusResponse<Object>	add(CPlusUser cPlusUser){
		boolean result = save(cPlusUser);
		if(result) {		
			return ResponseModelUtils.success();
		}
		return ResponseModelUtils.fail();
	}
	
	public CPlusResponse<Object>	modify(CPlusUser cPlusUser){

		boolean result = updateById(cPlusUser);
		if(result) {
			return ResponseModelUtils.success();
		}
		return ResponseModelUtils.fail();
	}
	
	public CPlusResponse<Page<CPlusUser>> pageList(CPlusUserPage cPlusUserPage){
        Page<CPlusUser> page = CPlusUserTransfer.toPage(cPlusUserPage);
		return ResponseModelUtils.body(page(page,new QueryWrapper<CPlusUser>()));
	}

	@Override
	public CPlusResponse<CPlusUser> getUser(String loginAccount) {

		return  ResponseModelUtils.body(this.getBaseMapper().getUser(loginAccount));


	}
}
